﻿using Microsoft.Win32;
using System.Windows.Controls;
using System.Windows.Media;

namespace MC.Warehouse.Core
{
    public class MethodHelper
    {
        private static RelayCommand _openFileDialog;
        public static RelayCommand OpentFileDialog
        {
            get { return _openFileDialog ?? (_openFileDialog = new RelayCommand(GetDialogImage)); }
        }

        private static void GetDialogImage(object param)
        {
            var data = param as Image;
            var dialog = new OpenFileDialog
                {
                    Filter = "Image files (*.bmp, *.jpg)|*.bmp;*.jpg|All files (*.*)|" +
                             "*.*"
                };
            dialog.ShowDialog();
            var imageSource = (ImageSource) new ImageSourceConverter().ConvertFromString(dialog.FileName);
            if (data != null) data.Source = imageSource;
        }

        public static bool IsProxy(object type)
        {
            return true;
            //return type != null && ObjectContext.GetObjectType(type.GetType()) != type.GetType();
        }

    }
}
